// 注册页面
const username = document.querySelector(".username")
const password = document.querySelector(".password")
const rpassword = document.querySelector(".rpassword")
const but = document.querySelector(".but")
but.addEventListener("click", async function () {
    let nameIpt = username.value
    let pwdIpt = password.value
    let rpwdIpt = rpassword.value
    if (!nameIpt || !pwdIpt || !rpwdIpt) return alert("请完整输入")
    if (pwdIpt !== rpwdIpt) return alert("两次输入的密码不一致，请完整输入")

    const data = `username=${nameIpt}&password=${pwdIpt}&${rpwdIpt}`
    const res = await pAjax({
        url:"../html/register.php",
        data,
        method: "post",
        dataType: "json"
    })
      if(res.code===0)return alert("用户名已存在")
      if(res.code===1){
          alert("注册成功请重新登录")
          window.location.href="../html/login.html"
      }
})
